package constant;

/**
 * @Description 属性类型常量
 * @Author zengzerui
 * @Date 2025/6/30
 */
public enum AttributeDataType {
    STRING(1, "字符串"),
    INTEGER(2, "整数"),
    DECIMAL(3, "小数"),
    BOOLEAN(4, "布尔值"),
    DATE(5, "日期"),
    DATETIME(6, "日期时间"),
    TIMESTAMP(7, "时间戳");

    private final int value;
    private final String description;

    AttributeDataType(int value, String description) {
        this.value = value;
        this.description = description;
    }

    public int getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    public static AttributeDataType fromValue(int value) {
        for (AttributeDataType type : values()) {
            if (type.value == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的数据类型值: " + value);
    }

    @Override
    public String toString() {
        return description;
    }
}
